<template>
  <el-tooltip effect="dark" :content="title" :disabled="!title" placement="bottom">
  <div class="svg-icon">
    <img 
      :width="width"
      :height="height"
      :src="require('../../assets/svgs/'+svgName+'.svg')" 
      @click="parentClick"
    />
  </div>
  </el-tooltip>
</template>

<script>

export default {
  name: 'SvgIcon',
  props: {
    // 显示的title
    title: {
      type: String,
      default: ''
    },
    // svg矢量图标名称：与项目中存放矢量图标的文件夹中的名称一致
    svgName: {
      type: String,
      default: ''
    },
    // svg矢量图标宽
    width: {
      type: String,
      default: '18px'
    },
    // svg矢量图标高
    height: {
      type: String,
      default: '18px'
    }
  },
  methods: {
    // 触发-父组件方法
    parentClick(){
      this.$emit("myclick");
    }
  }
}
</script>

<style lang="less" scoped>
.svg-icon {

  img{
    // width: 18px;
    // height: 18px;
    vertical-align: middle;
    overflow: hidden;

    svg{
      color: #fff;
    }
  }
  
}
</style>
